using System;
using System.Collections.Generic;
using System.Text;

namespace SanFS.MediaChangerLibrary
{
    public class DataTransferStorageElement : StorageElement, IDataTransferStorageElement
    {
        private bool    mIsReadOnly;
        private bool    mIsMounted;
        private string  mDevicePath;
        private string  mMountPount;
        
        internal DataTransferStorageElement()
            : base(ElementType.DataTransfer, null, 0, LoadStatus.Empty)
        {
        }
        
        public DataTransferStorageElement(IMediaChanger MediaChanger, int DeviceSlot, LoadStatus Status)
            : base(ElementType.DataTransfer, MediaChanger, DeviceSlot, Status)
        {
        }

        public override IStorageElement CreateInstance(IMediaChanger MediaChanger, int DeviceSlot, LoadStatus Status)
        {
            return new DataTransferStorageElement(MediaChanger, DeviceSlot, Status);
        }

        #region IDataTransferStorageElement Members

        /// <summary>
        /// Mount the media in the drive
        /// </summary>
        public void Mount()
        {
            if (IsMounted)
                throw new StorageElementException(this, "Element already mounted");
            if (Status == LoadStatus.Empty)
                throw new StorageElementException(this, "Element empty");
            try
            {
                mIsMounted = true;
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// Unmount the media in the drive
        /// </summary>
        public void Unmount()
        {
            if (!IsMounted)
                throw new StorageElementException(this, "Element not mounted");
            try
            {
                mIsMounted = false;
            }
            catch
            {
                throw;
            }
        }

        public bool IsReadOnly
        {
            get
            {
                return mIsReadOnly;
            }
        }

        public string DevicePath
        {
            get
            {
                return mDevicePath;
            }
            set
            {
                mDevicePath = value;
            }
        }

        public string MountPoint
        {
            get
            {
                return mMountPount;
            }
            set
            {
                mMountPount = value;
            }
        }

        public bool IsMounted
        {
            get
            {
                return mIsMounted;
            }
        }
        #endregion
    }  // END CLASS
}  // END NAMESPACE
